package com.trailer.base.net;

import android.os.Build;

import com.tencent.mmkv.MMKV;
import com.trailer.base.base.BApp;

import java.io.IOException;

import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;

public class BHeaderInterceptor implements Interceptor {
    @Override
    public Response intercept(Chain chain) throws IOException {

        Request request = chain.request().newBuilder()
                .addHeader("User-Agent", "type/android;app-version-code/" +  BApp.instance().config().getVersionCode() + ";app-version-name/" +  BApp.instance().config().getVersionName() + ";phone-brand/" + Build.BRAND + ";phone-model/" + Build.MODEL + ";system-version-code/" + Build.VERSION.SDK_INT + ";system-version-name/" + Build.VERSION.RELEASE)
                .addHeader("Content-Type", "application/json")
                .addHeader("token", MMKV.defaultMMKV().decodeString("token", ""))
                .build();

        return chain.proceed(request);
    }
}
